const express = require('express')
const expressJwt = require('express-jwt')
const app = express()
const {jwtKey} = require('./config')

app.use('/uploads',express.static('./uploads'))
app.use(require('cors')()) //解决跨域
app.use(express.json()) //解析 JSON 格式的请求体数据
app.use(express.urlencoded({extended: false}))//解析 URL-encoded 格式的请求体数据
app.use(expressJwt({secret:jwtKey, algorithms: ['HS256']})
    .unless({path: [/^\/api/]}))
app.use(require('./middlewares/error'))//错误处理中间件
// app.use(require('./routers/test'))//测试相关路由
app.use(require('./routers/video'))//视频相关路由
app.use(require('./routers/comment'))//评论相关路由
app.use(require('./routers/user'))//用户相关路由
// app.use('/admin',require('./routers/admin/admin'))//管理后台相关路由
app.use(require('./middlewares/highError'))//错误处理中间件

app.listen(3000,()=>{
  console.log('server is running at http://127.0.0.1:3000/')
})